package com.cloud.feign.controller;

import com.cloud.feign.service.FeignClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 2020/3/18
 * FeignClientController
 *
 * @author machuanpeng
 */
@RestController
public class FeignClientController {
    @Autowired
    private FeignClientService feignClientService;

    @GetMapping("/home")
    String home(@RequestParam(value = "name", defaultValue = "feign") String name) {
        return feignClientService.homeFeignService(name);
    }

    /**
     * 文件上传.
     * 2020/3/18
     *
     * @param file file
     * @return java.lang.String
     * @author machuanpeng
     */
    @PostMapping(value = "/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    String uploadFile(@RequestPart(value = "FeignFile") MultipartFile file) {
        return feignClientService.uploadFileFeignService(file);
    }
}
